export let captcha = {
  namespaced: true,
  state: {
    captcha_data: {},
  },
  actions: {
    getCaptchaData(store, data = {}) {
      let url = "/captcha/verify?phone=" + data.phone + "&captcha=" + data.captcha + "&ctcode=" + data.ctcode;
      return new Promise((resolve, reject) => {
        axios.get(url).then(({
          data
        }) => {
          store.commit("setCaptchaData", data);
          resolve(data)
        }).catch(() => {
          reject({
            "message": "验证码错误",
            "code": 503
          })
        });
      });
    },
  },
  mutations: {
    setCaptchaData(state, data) {
      state.captcha_data = data;
    },
  }
}
